<template>
  <div>
    <div class="container">
      <div class="handle-box">
        <el-input
          v-model="query.queryParam.fkUserName"
          placeholder="用户名"
          class="handle-input mr10"
        ></el-input>
        <el-input
          v-model="query.queryParam.fkExamName"
          placeholder="考试名"
          class="handle-input mr10"
        ></el-input>
        <el-button type="primary" icon="el-icon-search" @click="handleSearch"
          >搜索</el-button
        >
      </div>
      <el-table
        :data="tableData"
        border
        class="table"
        ref="multipleTable"
        header-cell-class-name="table-header"
      >
        <el-table-column
          prop="fkUserName"
          label="用户名"
          width="100"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="fkExamName"
          label="所属考试"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="operation"
          label="用户操作"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="createTime"
          label="创建时间"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="ipAddress"
          label="IP地址"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="info"
          label="详细内容"
          show-overflow-tooltip
        ></el-table-column>
      </el-table>
      <div class="pagination">
        <el-pagination
          background
          layout="total, prev, pager, next"
          :current-page="query.pageIndex"
          :page-size="query.pageSize"
          :total="total"
          @current-change="handlePageChange"
        ></el-pagination>
      </div>
    </div>
  </div>
</template>

<script>
var _this;
export default {
  name: "basetable",
  data() {
    return {
      query: {
        queryParam: {
          fkUserName: "",
          fkExamName: ""
        },
        pageIndex: 1,
        pageSize: 10,
      },
      tableData: [],
      total: 0,
    };
  },
  created() {
    this.getData();
    _this = this;
  },
  methods: {
    // 获取数据
    getData() {
      this.$post("/proctorlog/loglist", this.query).then((res) => {
        if (res.code === 0) {
          this.tableData = res.data.records;
          this.total = res.data.total || 1;
        }
      });
    },    
    // 触发搜索按钮
    handleSearch() {
      this.$set(this.query, "pageIndex", 1);
      this.getData();
    },
    // 分页导航
    handlePageChange(val) {
      this.$set(this.query, "pageIndex", val);
      this.getData();
    },
  },
};
</script>

<style>
.handle-box {
  margin-bottom: 20px;
}

.handle-select {
  width: 120px;
}

.handle-input {
  width: 150px;
  display: inline-block;
}
.table {
  width: 100%;
  font-size: 14px;
}
.red {
  color: #ff0000;
}
.mr10 {
  margin-right: 10px;
}
.table-td-thumb {
  display: block;
  margin: auto;
  width: 40px;
  height: 40px;
}
/deep/.el-upload {
  width: 150px;
  height: 210px;
}
.avatar-uploader .el-upload {
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.avatar-uploader .el-upload:hover {
  border-color: #409eff;
}
.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 150px;
  height: 210px;
  line-height: 150px;
  text-align: center;
}
.avatar {
  width: 150px;
  height: 210px;
  display: block;
}
.el-tooltip__popper {
  max-width: 500px;
}
</style>
